home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / pcw.zip / PLDEMO.C < prev    next >
C/C++ Source or Header  |  1991-10-16  |  4KB  |  93 lines

  1. /***********************************************************/
  2. /* Program Id.               PmnuDemo.C.                   */
  3. /* Author.                   Stan Milam.                   */
  4. /* Date Written.             03/12/89.                     */
  5. /*                                                         */
  6. /* Comments: This program demonstrates the use of the pop- */
  7. /* up menu capabilities of PC Windows.  Use the up & down  */
  8. /* arrow keys to change the selection. Press enter to make */
  9. /* a selection.  Or, press 1 thru 5 to select, or use the  */
  10. /* mouse to "point and shoot".                             */
  11. /***********************************************************/
  12.  
  13. #include <stdio.h>
  14. #include <pcwproto.h>
  15. #include <menu.h>
  16.  
  17. int pl_menu_demo(void) {
  18.  
  19.    WNDPTR *wnd, *savewnd, *iwnd;
  20.  
  21. /***********************************************************/
  22. /* Create and initialize the pick-list menu values.        */
  23. /***********************************************************/
  24.  
  25. static char *selections[] = {
  26.     "Methodology",
  27.     "Word Processors",
  28.     "C Compiler",
  29.     "Pascal Compiler",
  30.     "3270 Emulation",
  31.     "Communications",
  32.     "COBOL Compiler",
  33.     "MASM",
  34.     NULL
  35. };
  36.  
  37. /**********************************************************/
  38. /* PICKLIST contains elements concerning a picklist menu. */
  39. /* First, there is a pointer to the window to be used,    */
  40. /* then window parameters, border parms, title parms,     */
  41. /* selection bar parms, and finally a pointer back to our */
  42. /* menu options.                                          */
  43. /**********************************************************/
  44.  
  45.     static PICKLIST plmenu =  {
  46.        NULL,
  47.        15, 30, 19, 50, BLACK,LIGHTGRAY,          /* Window Parms */
  48.        2, RED,LIGHTGRAY,                         /* Border Parms */
  49.        " Main Menu ",TOP,MIDDLE,BLUE,LIGHTGRAY,  /* Title  Parms */
  50.        WHITE,BLUE,                               /* Select Bar color  */
  51.        selections,                               /* pointer to menu list */
  52.        0,0                                       /* bar position offset */
  53.     };
  54.  
  55.     static char *instructions[] = {
  56.        "To use  the Pick  List Menu  use the \30\31 arrow  keys,",
  57.        "to place the cursor  bar on  the  desired  selection",
  58.        "and then press  enter.  Or, use the Mouse  to  point",
  59.        "and shoot the  selection you want.  ESC or the right",
  60.        "Mouse  key will end the demo.   There  may  be  more",
  61.        "picks  than can be shown in the window. You may  use",
  62.        "the arrow  keys or the Mouse to scroll them.        ",
  63.        NULL
  64.     };
  65.  
  66.    int i = 0;
  67.    int mxr, mxc;
  68.  
  69.    chk_video_state(&mxr,&mxc);                   /* Get max rows & cols */
  70.    savewnd = wpush(1,1,mxr,mxc);                 /* Save entire screen */
  71.    if (!savewnd) return(3);                      /* Exit if cannot save */
  72.    bordercolor(BLUE,LIGHTGRAY);                  /* Set border color */
  73.    titlecolor(BLACK,LIGHTGRAY);                  /* Set the title color */
  74.    iwnd = wexplode(2,10,12,70,RED,LIGHTGRAY);    /* Make instruction window */
  75.    wtitle(iwnd,TOP,LEFT," Pick List Menu Instructions "); /* Title it */
  76.    w_block_write(iwnd, 2, CENTER,instructions);  /* Write instructions to it */
  77.    wnd = make_pick_list(&plmenu);                /* Make a popup window */
  78.    while (i != -1) {                             /* Do until Esc */
  79.       i = get_pick_list(&plmenu);                /* Get Menu return value */
  80.       if ( i == 27 ) continue;
  81.       if (mpresent) hide_mouse();
  82.       qhchar(22,1,7,BLUE,176,80);                /* Clear msg line */
  83.       qputs(22,99,RED,7,selections[i]);          /* Write the choice */
  84.       if (mpresent) show_mouse();
  85.    }
  86.    if (mpresent) hide_mouse();                   /* Hide the mouse */
  87.    wnd     = wpop(wnd);                          /* Get rid of menu */
  88.    iwnd    = wpop(iwnd);                         /* Get rid of instructions */
  89.    savewnd = wpop(savewnd);                      /* Restore msg row */
  90.    return(0);                                    /* And go home */
  91. }
  92.  
  93.